package org.wzl.service.bo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.wzl.service._do.UserInfo;
import org.wzl.service._do.UserLogin;
import org.wzl.service.bo.redis.RedisUserBO;

import java.util.Collection;
import java.util.List;

/**
 * @author: 卫志龙
 * @date: 2024年06月29日 10:35
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDetail implements UserDetails {

    private RedisUserBO redisUserBO;
    private Boolean enabled;
    private Collection<? extends GrantedAuthority> authorities;
    private Boolean accountNonExpired;
    private Boolean credentialsNonExpired;
    private Boolean accountNonLocked;
    private String password;
    private String username;

    public UserDetail(RedisUserBO redisUserBO) {
        this.redisUserBO = redisUserBO;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return List.of();
    }

    @Override
    public String getPassword() {
        return redisUserBO.getUserLogin().getPassword();
    }

    @Override
    public String getUsername() {
        return redisUserBO.getUserLogin().getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

}
